﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;

namespace ReadBooks.Comm
{
    public interface ICommRepository
         
    {
        /// <summary>
        /// 获取所有实体对象
        /// </summary>
        /// <returns></returns>
        IQueryable<T> All<T>() where T  : class,IEntity;

        /// <summary>
        /// 根据Lamda表达式来查询实体对象
        /// </summary>
        /// <param name="whereLambda"></param>
        /// <returns></returns>
        IQueryable<T> Where<T>(Expression<Func<T, bool>> whereLambda) where T : class,IEntity;

        /// <summary>
        /// 根据表达式获取实体数量
        /// </summary>
        /// <param name="whereLambda"></param>
        /// <returns></returns>
        int Count<T>(Expression<Func<T, bool>> whereLambda) where T : class,IEntity;

        /// <summary>
        /// 实体对象新增
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        int Add<T>(T model, bool IsCommit = true) where T : class,IEntity;

        /// <summary>
        /// 实体对象修改
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        int Update<T>(T model, bool IsCommit = true) where T : class,IEntity;

        /// <summary>
        /// 实体对象根据字段修改
        /// </summary>
        /// <param name="model"></param>
        /// <param name="proName"></param>
        /// <returns></returns>
        int Update<T>(T model, bool IsCommit = true, params string[] proName) where T : class,IEntity;

        /// <summary>
        /// 实体对象删除
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        int Delete<T>(T model, bool IsCommit = true) where T : class,IEntity;

        /// <summary>
        /// 删除复核条件的多个实体对象
        /// </summary>
        /// <param name="whereLambda"></param>
        /// <returns></returns>
        int Delete<T>(Expression<Func<T, bool>> whereLambda, bool IsCommit = true) where T : class,IEntity;
    }


}
